// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.audio.parameters;

import zombie.audio.FMODGlobalParameter;
import zombie.characters.IsoPlayer;

public final class ParameterHardOfHearing extends FMODGlobalParameter {
    private int m_playerIndex = -1;

    public ParameterHardOfHearing() {
        super("HardOfHearing");
    }

    @Override
    public float calculateCurrentValue() {
        IsoPlayer isoPlayer = this.choosePlayer();
        if (isoPlayer != null) {
            return isoPlayer.getCharacterTraits().HardOfHearing.isSet() ? 1.0F : 0.0F;
        } else {
            return 0.0F;
        }
    }

    private IsoPlayer choosePlayer() {
        if (this.m_playerIndex != -1) {
            IsoPlayer isoPlayer0 = IsoPlayer.players[this.m_playerIndex];
            if (isoPlayer0 == null) {
                this.m_playerIndex = -1;
            }
        }

        if (this.m_playerIndex != -1) {
            return IsoPlayer.players[this.m_playerIndex];
        } else {
            for (int _int = 0; _int < IsoPlayer.numPlayers; _int++) {
                IsoPlayer isoPlayer1 = IsoPlayer.players[_int];
                if (isoPlayer1 != null) {
                    this.m_playerIndex = _int;
                    return isoPlayer1;
                }
            }

            return null;
        }
    }
}
